package com.mdsoft.dao.context;

import java.util.ArrayList;
import java.util.List;

import com.mdsoft.context.Context;
import com.mdsoft.dao.GroupDao;
import com.mdsoft.po.Group;

public class ContextGroupDao implements GroupDao {

	@Override
	public void add(Group group) {
		List<Group> groups = (List<Group>) Context.getInstance().get(Context.GROUPS);
		if (groups == null) {
			groups = new ArrayList<Group>();
			Context.getInstance().put(Context.GROUPS, groups);
		}
		group.setId(Context.getInstance().nextSequence());
		groups.add(group);
	}

	@Override
	public Group getById(int groupId) {
		return null;
	}

	@Override
	public Group getByUserId(int userId) {
		return null;
	}

	@Override
	public List<Group> getAll() {
		List<Group> groups = (List<Group>) Context.getInstance().get(Context.GROUPS);
		return new ArrayList<Group>(groups);
	}

}
